package Servlet;

import Shiti.Dingdanti;
import Shiti.Shopti;
import Shiti.Userti;
import service.Dingdanservice;
import service.Shopservice;
import service.Userservice;

import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
import java.io.PrintWriter;
import java.util.ArrayList;
@WebServlet("/querydingservlet")
public class querydingservlet extends HttpServlet {
    @Override
    protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
        request.setCharacterEncoding("utf-8");
        response.setContentType("text/html;utf-8");
        response.setCharacterEncoding("utf-8");
        PrintWriter out = response.getWriter();
        int acc= Integer.parseInt(request.getParameter("acc1"));
        ArrayList<Dingdanti> list =new ArrayList<Dingdanti>();
        Userti userti = new Userti(acc);
        Dingdanservice dingdanservice = new Dingdanservice();
        list.clear();
        list=dingdanservice.query(userti);
        if (list!=null){
            out.println("acc"+"\t"+"name"+"\t"+"bus"+"\t"+"id"+"\t"+"num");
            for (int i=0;i<list.size();i++){
                Dingdanti s = (Dingdanti) list.get(i);
                response.getWriter().write("<br>");
                out.println(s.getAcc()+"\t"+s.getName()+"\t"+s.getBus()+"\t"+s.getId()+"\t"+s.getNum());
                response.getWriter().write("<br>");
                out.println("---------------------------");
            }
        }
        else {
            out.println("错误");
        }

    }
    @Override
    protected void doPost(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
        doGet(req, resp);
    }
}
